from models import db

class User(db.Model):
    __tablename__ = "user"
    id = db.Column(db.Integer,primary_key=True)
    password = db.Column('password',db.String(32))
    phone = db.Column('phone',db.String(11),unique=True)
    money = db.Column(db.Integer,default=0)
    flags = db.relationship('Flag',backref='user',lazy='dynamic')
    # orders = db.relationship('Order',backref='user',lazy='dynamic')

    def __repr__(self):
        return self.phone

class Flag(db.Model):
    __tablename__ = "flag"
    id = db.Column(db.Integer,primary_key=True)
    code = db.Column('code',db.String(16))
    isused = db.Column('isused',db.Boolean(0))
    user_id = db.Column(db.Integer,db.ForeignKey('user.id'))
    price = db.Column(db.Integer)

    def __repr__(self):
        return self.code

class Feedback(db.Model):
    __tablename__ = "feedback"
    id = db.Column(db.Integer,primary_key=True)
    email = db.Column(db.String(32))
    feedback = db.Column(db.String(128))

    def __repr__(self):
        return str(self.id)
